/**
 * Copyright 2008 Martin 'Windgazer' Reurings
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package nl.windgazer.maven.plugins.jsdoc;

import org.apache.maven.plugin.logging.Log;

/**
 * Obsolete
 * 
 * @deprecated
 * @author mreuring
 */
public class JSDocSecurityManager extends SecurityManager {
	private Log log = null;
	private int firstExitStatus = -1; //Rhino is throwing a curve-ball by intercepting the first system.exit() and throwing it's own after that...
	private int lastExitStatus;
	
	public JSDocSecurityManager(Log log) {
		this.log = log;
	}

	public void checkExit(int status) {
		debug("Thread is requesting exit permissions, will be denied");
		if (firstExitStatus < 0) firstExitStatus = status;
		lastExitStatus = status;
		throw new SecurityException("Preventing System.exit(" + Integer.toString(status) + ")!");
	}

	private void debug(String msg) {
		if (this.log!=null)log.debug(msg);
	}

	public int getFirstExitStatus() {
		return firstExitStatus;
	}

	public int getLastExitStatus() {
		return lastExitStatus;
	}
}
